package com.example.toy.core.filter;

import com.example.toy.core.record.ToyRecord;
import java.io.Serializable;

/**
 * 过滤器
 */
@FunctionalInterface
public interface ToyFilter extends Serializable {

  boolean accept(ToyRecord record);

  default <T extends ToyFilter> ToyFilter and(T filter) {
    return new Filters.And(this, filter);
  }

  default <T extends ToyFilter> ToyFilter or(T filter) {
    return new Filters.Or(this, filter);
  }

  default <T extends ToyFilter> ToyFilter not() {
    return new Filters.Not(this);
  }
}
